<template>
    <div @click="showFullImg" class="text" :class= "'chatMessageText' + index" ref="chatMessage">
    </div>
</template>

<script>
    export default {
        name: "chatMessage",
        data(){
                return{
                    id: undefined,
                    textarea: ''
                }
            },
        props:['message', 'index', 'msgType','fileurl'],
        mounted(){
            const className = "chatMessageText" + this.index;
            const lastClass = $('.chatMessageText').length - 1;
            $('.'+ className).append(this.message);
            // div.append('<img src="../../static/images/editor/emotion/qq/12.gif"> ');
        },
        methods: {
            showFullImg() {
                if(this.msgType === 'image'){
                    var src = this.$refs.chatMessage.children[0].src;
                    this.$parent.showFullImg(src);
                }else if(this.msgType ==='file'){
                  console.log(this.fileurl);
                  //打开新页面
                  window.open(this.fileurl);
                }
            }
        }
    }
</script>

<style scoped>

</style>
